
use "D:\百度云同步盘\清华\科研\数据\中国私营企业调查2014-2018\2018 data (clean).dta",clear

*行业类型 (实体vs非实体-房地产和金融保险)-参考范晓光和吕鹏(2018)
g indus_1 = V71
replace indus_1 =. if indus_1 == 99

save "D:\百度云同步盘\清华\科研\数据\中国私营企业调查2014-2018\2018_temp.dta",replace

collapse (mean) party_ind=V182, by(indus_1) 

sort indus_1

save "D:\百度云同步盘\清华\科研\论文\He & Liu\制度涉入和家族企业应对\数据\party_ind_temp2018.dta",replace

merge 1:m  indus_1 using "D:\百度云同步盘\清华\科研\数据\中国私营企业调查2014-2018\2018_temp.dta"

*g indus_1 = V71
*replace indus_1 =. if indus_1 == 99

replace party_ind=. if indus_1==.

drop indus_1

g year = 2018


gen id=_n



********************************************************************************
********************************* 控制变量 *********************************
********************************************************************************

*企业注册类型(当前)
tab V68
tab V68, nol // 1=一人公司 2=独资企业 3=合伙企业 4=有限责任公司 5=股份有限公司
g regi_type = V68
replace regi_type =. if regi_type ==9

*****************************
*** Firm Level ***
*****************************

*企业历史
tab v11
g firm_year = 2018-v11+1
replace firm_year = . if firm_year < 0

*雇员人数 (注意奇异值问题，如果去掉奇异值会导致对企业绩效的影响不显著)
sum V79,de
tab V79, nol // 1.00e+08
g employee = V79
replace employee =. if employee < 0
replace employee =. if employee == 110172 // 奇异值
replace employee =. if employee == 1.00e+08 // 奇异值

g log_employee = log(employee+1)  

***企业资本构成(最近1年)

**correct some error records
replace V77=0 if id==47
replace V77=0 if id==161
replace V75=95 if id==239
replace V75=0 if id==404
replace V77=55 if id==642
replace V75=0 if id==1046
replace V76=0 if id==1046
replace V77=0 if id==1046
replace V75=0 if id==1189
replace V77=25 if id==1428
replace V75=0 if id==1588
replace V77=0 if id==2016
replace V75=0 if id==2052
replace V75=0 if id==3308
replace V77=0 if id==3935
replace V77=15 if id==4738
replace V75=0 if id==5296 | id==5306
replace V76=0 if id==5296 | id==5306
replace V77=0 if id==5296 | id==5306
replace V75=49 if id==5472
replace V77=19 if id==5686
replace V75=0 if id==5917
replace V77=0 if id==6038
replace V77=4 if id==6087
replace V75=30 if id==6161
replace V77=30 if id==6162
replace V75=0 if id==6162
replace V77=15 if id==6284
replace V76=0 if id==6478
replace V77=80 if id==6884
replace V77=40 if id==7117
replace V75=0 if id==7117
replace V77=18.47 if id==7168
replace V77=38.21 if id==7328
replace V77=17.29 if id==7274

/*
     +------------------------------------+
      |   id     V74     V75   V76     V77 |
      |------------------------------------|
5472. | 5472      51      50     0       0 |
5917. | 5917     100      20     0       0 |
6162. | 6162      70     100     0      30 |
7117. | 7117      50      10     0      50 |
7274. | 7274   57.82   24.89     0   17.31 |
      +------------------------------------+


*总额(万元)
sum V78
g interest_total = V78
replace interest_total =. if interest_total <0
*/


*您自己和家人(衡量家族涉入) %
g interest_of = V74
replace interest_of =. if interest_of <0
replace interest_of =. if interest_of > 100

***企业重大决策权
*null

***企业日常管理
*null

*********************
*Industry Level
*********************

*行业类型 (实体vs非实体-房地产和金融保险)-参考范晓光和吕鹏(2018)
tab V71 // 1-19
tab V71, nol // 1-19
tab V72
tab V73
g indus_1 = V71
g indus_2 = V72
g indus_3 = V73
replace indus_1 =. if indus_1 == 99
replace indus_2 =. if indus_2 == 99
replace indus_3 =. if indus_3 == 99

/*
recode indus_1 10/11=0 1/9=1 12/15=1  // 0=非实体 1=实体
recode indus_2 10/11=0 1/9=1 12/15=1  // 0=非实体 1=实体
recode indus_3 10/11=0 1/9=1 12/15=1  // 0=非实体 1=实体
g indus_real = indus_1
tab indus_real
*/

g industry_man = .
replace industry_man = 0 if indus_1 != 3 & indus_2 != 3 & indus_3 != 3  // 非制造业
replace industry_man = 1 if indus_1 == 3 | indus_2 == 3 | indus_3 == 3  // 制造业
tab industry_man


********************************************************************************
***********************************Individual Level****************************
********************************************************************************

*性别
tab V20
tab V20, nol // 男=1 女=2
g gender = V20
replace gender = . if gender == 9
recode gender 1=1 2=0  // 女=0 男=1

*年龄/出生年份
tab V21
g age = 2018-V21

*学历 (0=初中及以下 1=高中 2=大专及以上)-参考范晓光和吕鹏(2018)
tab V22
tab V22, nol 
   // 1=初中及以下  2=高中/职高/中专/技校  3=大专 4= 本科(含双学士) 5=硕士 6-博士 9=未回答
g edu_cate = V22
replace edu_cate = . if edu_cate == 9
recode edu_cate 1=0 2=1 3/6=2 
tab edu_cate

*学历 (0=高中及以下 1=大专及以下)
tab V22
tab V22, nol 
g edu_dummy = V22
replace edu_dummy = . if edu_dummy == 9
recode edu_dummy 1/2=0 3/6=1
tab edu_dummy   

*政治面貌
tab V25 // 1=党员 2=民主党派  3-未参加
tab V25, nol
replace V25 =. if V25 == 9
g party_mem = .
replace party_mem = 1 if V25 == 1
replace party_mem = 0 if V25 == 2 | V25 == 3 | V25==.
tab party_mem


*两委委员
tab V28
tab V28, nol // 1=是 0=不是
g twocm = V28
tab twocm // 1=是 0=不是

*工商联
tab V44 // 1=是 2=否
tab V44, nol
g gongshanglian = V44
replace gongshanglian = . if gongshanglian == 9
recode gongshanglian 1=1 2=0 // 1=是 0=否
tab gongshanglian

*地位感知(经济/社会/政治) 数值越小，地位越高
tab v2 // 收入水平 1-10
tab v3 // 社会地位
tab v4 // 政治参与
g status_e = v2
g status_s = v3
g status_p = v4
replace status_e =. if status_e <0
replace status_s =. if status_s <0
replace status_p =. if status_p <0
replace status_e =. if status_e >10
replace status_s =. if status_s>10
replace status_p =. if status_p>10
g status_tl = (status_e+status_s+status_p)/3


********************************************************************************
********************************* 党建 *********************************
********************************************************************************


**设立党组织(在您的企业中，有无下列组织?)   
sum V179 // 股东会
sum V180 // 董事会
sum V181 // 监事会
sum V182 // 党支部  0=无 1=有
sum V183 // 工会
sum V184 // 职工代表大会
g structure_share = V179
g structure_chair = V180
g structure_audit = V181
g structure_party = V182
g structure_union = V183
g structure_assemble = V184
tab structure_party



*是否担任企业党委书记
tab V15 // 党委书记
tab V15, nol // 1=是 0=不是
g firm_shuji = V15 


*兼任党委书记
tab V12 // 董事长
tab V13 // 总经理
tab V14 // 企业副职
tab V15 // 党委书记
tab V15, nol // 1=是
tab V16 // 董事
tab V17 // 部门负责人
g concurrent = .
replace concurrent = 1 if V15 == 1 & V12 == 1
replace concurrent = 1 if V15 == 1 & V13 == 1
replace concurrent = 1 if V15 == 1 & V14 == 1
replace concurrent = 1 if V15 == 1 & V16 == 1
replace concurrent = 1 if V15 == 1 & V17 == 1
replace concurrent = 0 if concurrent ==.
tab concurrent


*A.如果贵企业建有中共党组织，党组织发挥的作用？
tab v46 // 文化
tab v46, nol // 1=是，0=否
tab v47 // 团结
tab v48 // 人才
tab v49 // 诚信经营
tab v50  // 与政府沟通
tab v51 // 技术、业务发展
tab v52  // 经济效益
tab V197 // 其它
g f_s1 = v48
g f_s2 = v50
g f_s3 = v51
g f_s4 = v52
g f_x1 = v46
g f_x2 = v47
g f_x3 = v49
g party_func = .
replace party_func = 1 if v48 == 1 
replace party_func = 1 if v50 == 1 
replace party_func = 1 if v51 == 1 
replace party_func = 1 if v52 == 1
replace party_func = 0 if v46 == 0
replace party_func = 0 if v47 == 0
replace party_func = 0 if v49 == 0
tab party_func // 1=务实 0=务虚

*B.党组织是由哪一级上级党组织进行管理的？
sum V198 V199 V200 V201
 // （1）属地党委 □ （2）当地工商联党组 （3）个体私营企业协会党组织 □ （4）街道社区党组织、社会工委
 
*C.如果没有建立中共党组织，原因是什么？（可选多项）
sum V202 V203 V204 V205 V206 V207 V208 V209 V210
 // （1）党员数量少 （2）党员流动性大 （3）不了解职工中是否有党员 □ （4）不知道如何建立党组织 （5）没有经费开展党组织活动 □ （6）担心党组织干预企业经营自主权 □
 // （7）增加企业开支 □ （8）其他（请注明）

 

********************************************************************************
********************************* 经营 *********************************
********************************************************************************

*企业资产 - 所有者权益总额(万元)
sum V78
*g interest_total = V78
*replace interest_total =. if interest_total <0

******
*绩效*
******

*销售收入
g revenue_latest = V110
replace revenue_latest =. if revenue_latest < 0
g log_revenue_latest = log(revenue_latest+1)

winsor2 revenue_latest, cuts(1 99) suffix(_w) label // 缩尾
sum revenue_latest_w 
g log_revenue_latest_w = log(revenue_latest_w+1)

*利润
sum V117
g profit_latest = V117
replace profit_latest =. if profit_latest < 0

**missing value
replace profit_latest=. if profit>95500 & profit<100000

g log_profit_latest = log(profit_latest+1)

winsor2 profit_latest, cuts(1 99) suffix(_w) label // 缩尾
sum profit_latest_w profit_latest
g log_profit_latest_w = log(profit_latest_w+1)



******
*投资
******

*新增投资(万元)
g invest = V135  // 费用
replace invest =. if invest < 0 
sum invest
g log_invest = log(invest+1)

winsor2 invest, cuts(1 99) suffix(_w) label // 缩尾
sum invest_w 
g log_invest_w = log(invest+1)

*是否投资
g invest_dummy = invest  // 是否
replace invest_dummy = 0 if invest_dummy == 0 
replace invest_dummy = 1 if invest_dummy > 0 
tab invest_dummy

*新增投资/销售收入(强度)
g invest_ratio = invest / revenue_latest
replace invest_ratio =. if invest_ratio < 0
replace invest_ratio =. if invest_ratio > 100 
replace invest_ratio =. if invest_ratio > 1

g invest_ratio_w = invest_w / revenue_latest_w // 缩尾
replace invest_ratio_w =. if invest_ratio_w < 0
replace invest_ratio_w =. if invest_ratio_w > 100 
replace invest_ratio_w =. if invest_ratio_w > 1

************
*创新
************

*创新投入:研发投入(万元)
g inno_in = V273 
replace inno_in =. if inno_in < 0
g log_inno_in = log(inno_in+1)

*创新投入:是否研发投入
g inno_in_dummy = inno_in // 是否
replace inno_in_dummy = 0 if inno_in_dummy == 0
replace inno_in_dummy = 1 if inno_in_dummy > 0
tab inno_in_dummy

*创新投入:研发投入/销售收入
g inno_in_ratio = inno_in / revenue_latest  // 强度
replace inno_in_ratio =. if inno_in_ratio < 0
replace inno_in_ratio =. if inno_in_ratio > 100
replace inno_in_ratio =. if inno_in_ratio > 1

*创新产出：知识产权(专利、商标等)
g inno_out = v63
replace inno_out =. if inno_out < 0

********************************************************************************
********************************* 资源获取 *********************************
********************************************************************************

************
*贷款
************

*银行贷款(国有银行+股份制银行)(万元)
g loan_bank = v23
replace loan_bank =. if loan_bank < 0
g log_loan_bank = log(loan_bank+1)

winsor2 loan_bank, cuts(1 99) suffix(_w) label // 缩尾
sum loan_bank_w loan_bank
g log_loan_bank_w = log(loan_bank+1)

*国有银行 (万元)
//null

*城市商业银行(万元)
//null

*银行 (万元)
//null

*民间贷款 (万元)
g loan_private = V106
replace loan_private =. if loan_private < 0
g log_loan_private = log(loan_private+1)

************
*政府补贴
************
sum V116
g subsidy = V116
replace subsidy =. if subsidy <0
g log_subsidy = log(subsidy+1)

winsor2 subsidy, cuts(1 99) suffix(_w) label // 缩尾
sum subsidy_w subsidy
g log_subsidy_w = log(subsidy_w+1)

********************************************************************************
********************************* 行政干预 *********************************
********************************************************************************
//"维系性政治成本：三项支出：缴费、摊派和公关招待费（陈光金，2004）"

*摊派 (万元)
g tanpai = V113  // 费用
replace tanpai =. if tanpai < 0 
g log_tanpai = log(tanpai+1)

*是否摊派
g tanpai_dummy = tanpai  // 是否
replace tanpai_dummy = 0 if tanpai_dummy == 0 
replace tanpai_dummy = 1 if tanpai_dummy > 0 

*摊派/销售收入
g tanpai_ratio = tanpai / revenue_latest 
replace tanpai_ratio =. if tanpai_ratio < 0
replace tanpai_ratio =. if tanpai_ratio > 100

*应酬(万元)
g yingchou = V114  // 费用
replace yingchou =. if yingchou < 0 
g log_yingchou = log(yingchou+1)

*是否应酬
g yingchou_dummy = yingchou  // 是否
replace yingchou_dummy = 0 if yingchou_dummy == 0 
replace yingchou_dummy = 1 if yingchou_dummy > 0 
tab yingchou_dummy

*应酬/销售收入
g yingchou_ratio = yingchou / revenue_latest  // 强度
replace yingchou_ratio =. if yingchou_ratio < 0
replace yingchou_ratio =. if yingchou_ratio > 100

*规费(万元)
g guifei = V112  // 费用
replace guifei =. if guifei < 0 
g log_guifei = log(guifei+1)

*是否规费
g guifei_dummy = guifei  // 是否
replace guifei_dummy = 0 if guifei_dummy == 0 
replace guifei_dummy = 1 if guifei_dummy > 0 
tab guifei_dummy

*规费/销售收入
g guifei_ratio = guifei / revenue_latest  // 强度
replace guifei_ratio =. if guifei_ratio < 0
replace guifei_ratio =. if guifei_ratio > 100



********************************************************************************
********************************* 外部社会责任 *********************************
********************************************************************************

*******
*捐赠*
******
*drop juan log_juan juan_dummy juan_ratio

*捐赠费用 万元
g juan = V115 
replace juan =. if juan < 0 
replace juan =. if juan > 99999
g log_juan = log(juan+1)
sum juan

winsor2 juan, cuts(1 99) suffix(_w) label // 缩尾
sum juan_w juan
g log_juan_w = log(juan_w+1)

*是否捐赠
g juan_dummy = juan 
replace juan_dummy = 0 if juan_dummy == 0 
replace juan_dummy = 1 if juan_dummy > 0 
tab juan_dummy

*捐赠费用/销售收入
g juan_ratio = juan/revenue_latest 
sum juan_ratio
replace juan_ratio =. if juan_ratio > 1

g juan_ratio_w = juan_w/revenue_latest_w  // 缩尾
sum juan_ratio_w
replace juan_ratio_w =. if juan_ratio_w > 1

**********
*治理污染*
**********
*drop zhiwu log_zhiwu zhiwu_dummy zhiwu_ratio

*治污费用 万元
g zhiwu = v85  // 费用
replace zhiwu =. if zhiwu < 0 
replace zhiwu =. if zhiwu > 99999
sum zhiwu
g log_zhiwu = log(zhiwu+1)

winsor2 zhiwu, cuts(1 99) suffix(_w) label // 缩尾
sum zhiwu_w zhiwu
g log_zhiwu_w = log(zhiwu_w+1)

*是否治污
g zhiwu_dummy = zhiwu  // 是否
replace zhiwu_dummy = 0 if zhiwu_dummy == 0 
replace zhiwu_dummy = 1 if zhiwu_dummy > 0 
tab zhiwu_dummy

*治污费用/销售收入
g zhiwu_ratio = zhiwu/revenue_latest  // 强度
sum zhiwu_ratio
replace zhiwu_ratio =. if zhiwu_ratio > 1

g zhiwu_ratio_w = zhiwu_w /revenue_latest_w  // 强度
sum zhiwu_ratio_w
replace zhiwu_ratio_w =. if zhiwu_ratio_w > 1


********************************************************************************
********************************* 内部社会责任 *********************************
********************************************************************************

********
*工资*
********
*drop wage log_wage per_wage log_per_wage wage_ratio

*总工资
sum V95
g wage = V95
replace wage =. if wage < 0
replace wage =. if wage > 99999
sum wage
g log_wage = log(wage+1)

*人均工资(手动计算)
g per_wage = wage / employee
sum per_wage, de
g log_per_wage = log(per_wage+1)

winsor2 per_wage, cuts(1 99) suffix(_w) label // 缩尾
sum per_wage_w per_wage
g log_per_wage_w = log(per_wage_w+1)

*工资和奖金/销售收入
g wage_ratio = wage/revenue_latest
sum wage_ratio
replace wage_ratio =. if wage_ratio > 1

********
*劳保*
********
*null

************
*社会保险(合计)*
************
*drop ins_fare log_ins_fare ins_fare_ratio

*单项参保人数
//null

*单项社保支出
//null

*人均社保费用(单项)
//null

*参保率(单项)
//null

*总社保支出
g ins_fare = V96 
replace ins_fare =. if ins_fare <0
replace ins_fare =. if ins_fare > 99999
sum ins_fare
g log_ins_fare = log(ins_fare+1)

*总社保支出/销售收入
g ins_fare_ratio = ins_fare/revenue_latest
sum ins_fare_ratio
replace ins_fare_ratio =. if ins_fare_ratio > 1

*总参保人数
g ins_num = V97
replace ins_num =. if ins_num <0

*是否有社保支出
g ins_fare_dummy = ins_fare // 是否
replace ins_fare_dummy = 0 if ins_fare_dummy == 0
replace ins_fare_dummy = 1 if ins_fare_dummy > 0

*总人均社保支出
g per_ins_fare = ins_fare/employee  
replace per_ins_fare =. if per_ins_fare <0
g log_per_ins_fare = log(per_ins_fare+1)

winsor2 per_ins_fare, cuts(1 99) suffix(_w) label // 缩尾
sum per_ins_fare_w per_ins_fare
g log_per_ins_fare_w = log(per_ins_fare_w+1)

*总参保率(参保人数/职工数)
g ins_num_ratio = ins_num/employee
replace ins_num_ratio =. if ins_num_ratio <0
replace ins_num_ratio =. if ins_num_ratio >1



********************************************************************************
********************************* 家族涉入 *********************************
********************************************************************************

***所有者权益占比
*您自己和家人(衡量家族涉入) %
*g interest_of = V74
*replace interest_of =. if interest_of <0
*replace interest_of =. if interest_of > 100

********************************************************************************
*************************** Regional Level **************************
********************************************************************************

******省份
g shengfen = V5
g prov =.
replace	prov	=	110000	if	shengfen	==	1
replace	prov	=	120000	if	shengfen	==	2
replace	prov	=	130000	if	shengfen	==	3
replace	prov	=	140000	if	shengfen	==	4
replace	prov	=	150000	if	shengfen	==	5
replace	prov	=	210000	if	shengfen	==	6
replace	prov	=	220000	if	shengfen	==	7
replace	prov	=	230000	if	shengfen	==	8
replace	prov	=	310000	if	shengfen	==	9
replace	prov	=	320000	if	shengfen	==	10
replace	prov	=	330000	if	shengfen	==	11
replace	prov	=	340000	if	shengfen	==	12
replace	prov	=	350000	if	shengfen	==	13
replace	prov	=	360000	if	shengfen	==	14
replace	prov	=	370000	if	shengfen	==	15
replace	prov	=	410000	if	shengfen	==	16
replace	prov	=	420000	if	shengfen	==	17
replace	prov	=	430000	if	shengfen	==	18
replace	prov	=	440000	if	shengfen	==	19
replace	prov	=	450000	if	shengfen	==	20
replace	prov	=	460000	if	shengfen	==	21
replace	prov	=	500000	if	shengfen	==	22
replace	prov	=	510000	if	shengfen	==	23
replace	prov	=	520000	if	shengfen	==	24
replace	prov	=	530000	if	shengfen	==	25
replace	prov	=	540000	if	shengfen	==	26
replace	prov	=	610000	if	shengfen	==	27
replace	prov	=	620000	if	shengfen	==	28
replace	prov	=	630000	if	shengfen	==	29
replace	prov	=	640000	if	shengfen	==	30
replace	prov	=	650000	if	shengfen	==	31
replace	prov	=	650000	if	shengfen	==	32
tab prov
 
**地区 : 2=东部 1=中部 0=西部
g diqu =.
replace	diqu	=	2	if	prov	==	110000
replace	diqu	=	2	if	prov	==	120000
replace	diqu	=	2	if	prov	==	130000
replace	diqu	=	1	if	prov	==	140000
replace	diqu	=	1	if	prov	==	150000
replace	diqu	=	2	if	prov	==	210000
replace	diqu	=	1	if	prov	==	220000
replace	diqu	=	1	if	prov	==	230000
replace	diqu	=	2	if	prov	==	310000
replace	diqu	=	2	if	prov	==	320000
replace	diqu	=	2	if	prov	==	330000
replace	diqu	=	1	if	prov	==	340000
replace	diqu	=	2	if	prov	==	350000
replace	diqu	=	1	if	prov	==	360000
replace	diqu	=	2	if	prov	==	370000
replace	diqu	=	1	if	prov	==	410000
replace	diqu	=	1	if	prov	==	420000
replace	diqu	=	1	if	prov	==	430000
replace	diqu	=	2	if	prov	==	440000
replace	diqu	=	2	if	prov	==	450000
replace	diqu	=	2	if	prov	==	460000
replace	diqu	=	0	if	prov	==	500000
replace	diqu	=	0	if	prov	==	510000
replace	diqu	=	0	if	prov	==	520000
replace	diqu	=	0	if	prov	==	530000
replace	diqu	=	0	if	prov	==	540000
replace	diqu	=	0	if	prov	==	610000
replace	diqu	=	0	if	prov	==	620000
replace	diqu	=	0	if	prov	==	630000
replace	diqu	=	0	if	prov	==	640000
replace	diqu	=	0	if	prov	==	650000
tab diqu 

********************************************************************************
********************* 制度环境感知 *********************
********************************************************************************

***营商环境感知
tab V355, nol // 1=明显改善 5=完全没有改善 6=不知道(drop) 9=未回答(drop)
/*             // 调整编码：数值越大，越积极
A.行政审批手续更加方便、简捷
B.节省了工商证照办理时间
C.工商行政机关公正执法
D.企业注册更加灵活
E.企业年报程序简洁便利
F．“五证合一”时换证手续简化
G.政府官员勤政、积极服务企业
H.市场监管部门运动式执法
G.企业从国有银行贷款的难易程度 
H.企业从民间渠道筹资的难易程度
K.找到需要的熟练工人 
L.整体营商环境 
*/
g en_1  = V355
g en_2  = V356
g en_3  = V357
g en_4  = V358
g en_5  = V359
g en_6  = V360
g en_7  = V361
g en_8  = V362
g en_9  = v102
g en_10  = v103
g en_11  = V365
g en_12  = V366 // 总体感知(去掉)
replace en_1  =. if en_1  == 6
replace en_2  =. if en_2  == 6
replace en_3  =. if en_3  == 6
replace en_4  =. if en_4  == 6
replace en_5  =. if en_5  == 6
replace en_6  =. if en_6  == 6
replace en_7  =. if en_7  == 6
replace en_8  =. if en_8  == 6
replace en_9  =. if en_9  == 6
replace en_10  =. if en_10  == 6
replace en_11  =. if en_11  == 6
replace en_12  =. if en_12  == 6
replace en_1  =. if en_1  == 9
replace en_2  =. if en_2  == 9
replace en_3  =. if en_3  == 9
replace en_4  =. if en_4  == 9
replace en_5  =. if en_5  == 9
replace en_6  =. if en_6  == 9
replace en_7  =. if en_7  == 9
replace en_8  =. if en_8  == 9
replace en_9  =. if en_9  == 9
replace en_10  =. if en_10  == 9
replace en_11  =. if en_11  == 9
replace en_12  =. if en_12  == 9
recode en_1 1=500 2=400 3=300 4=200 5=100
recode en_2 1=500 2=400 3=300 4=200 5=100
recode en_3 1=500 2=400 3=300 4=200 5=100
recode en_4 1=500 2=400 3=300 4=200 5=100
recode en_5 1=500 2=400 3=300 4=200 5=100
recode en_6 1=500 2=400 3=300 4=200 5=100
recode en_7 1=500 2=400 3=300 4=200 5=100
recode en_8 1=500 2=400 3=300 4=200 5=100
recode en_9 1=500 2=400 3=300 4=200 5=100
recode en_10 1=500 2=400 3=300 4=200 5=100
recode en_11 1=500 2=400 3=300 4=200 5=100
recode en_12 1=500 2=400 3=300 4=200 5=100
recode en_1 500=5 400=4 300=3 200=2 100=1
recode en_2 500=5 400=4 300=3 200=2 100=1
recode en_3 500=5 400=4 300=3 200=2 100=1
recode en_4 500=5 400=4 300=3 200=2 100=1
recode en_5 500=5 400=4 300=3 200=2 100=1
recode en_6 500=5 400=4 300=3 200=2 100=1
recode en_7 500=5 400=4 300=3 200=2 100=1
recode en_8 500=5 400=4 300=3 200=2 100=1
recode en_9 500=5 400=4 300=3 200=2 100=1
recode en_10 500=5 400=4 300=3 200=2 100=1
recode en_11 500=5 400=4 300=3 200=2 100=1
recode en_12 500=5 400=4 300=3 200=2 100=1

// 平均值法
g en_total =(en_1+en_2+en_3+en_4+en_5+en_6+en_7+en_8+en_9+en_10+en_11)/11 

egen en_total2=rowmean(en_1 en_2 en_3 en_4 en_5 en_6 en_7 en_8 en_9 en_10 en_11)




*主成分法
factor en_1 - en_11, pcf
rotate
*生成因子分
predict f1 f2
g f_be = (f1*0.4849)+(f2*0.2559) 


*KMO检验
estat kmo
*bartlett球形检验
*ssc install factortest // 然后安装，装好之后输入： 
factortest en_1 - en_11 
*信度系数 （Cronbach's α） - 针对某一公因子包括的观测指标
alpha en_1 - en_8
alpha en_9 - en_11


***法治环境感知
tab v104
tab v104, nol // 1=非常满意 5=非常不满意 6=不知道(drop) 9=未回答(drop)
			  // 调整编码：数值越大，越积极
/*A.对失信主体的惩戒
B.企业家和家人的人身安全保障
C.财产和财富的安全 
D.企业家人格权的保护
E.知识产权保护 
F.法律、法规的完备
G.合作企业的法治意识
H.司法机关的立案效率
I.法院判决书的执行情况
*/
g fa_1  = v104
g fa_2  = v105
g fa_3  = v106
g fa_4  = v107
g fa_5  = v108
g fa_6  = v109
g fa_7  = v110
g fa_8  = v111
g fa_9  = v112
replace fa_1  =. if fa_1  == 6
replace fa_2  =. if fa_2  == 6
replace fa_3  =. if fa_3  == 6
replace fa_4  =. if fa_4  == 6
replace fa_5  =. if fa_5  == 6
replace fa_6  =. if fa_6  == 6
replace fa_7  =. if fa_7  == 6
replace fa_8  =. if fa_8  == 6
replace fa_9  =. if fa_9  == 6
replace fa_1  =. if fa_1  == 9
replace fa_2  =. if fa_2  == 9
replace fa_3  =. if fa_3  == 9
replace fa_4  =. if fa_4  == 9
replace fa_5  =. if fa_5  == 9
replace fa_6  =. if fa_6  == 9
replace fa_7  =. if fa_7  == 9
replace fa_8  =. if fa_8  == 9
replace fa_9  =. if fa_9  == 9
recode fa_1 1=500 2=400 3=300 4=200 5=100
recode fa_2 1=500 2=400 3=300 4=200 5=100
recode fa_3 1=500 2=400 3=300 4=200 5=100
recode fa_4 1=500 2=400 3=300 4=200 5=100
recode fa_5 1=500 2=400 3=300 4=200 5=100
recode fa_6 1=500 2=400 3=300 4=200 5=100
recode fa_7 1=500 2=400 3=300 4=200 5=100
recode fa_8 1=500 2=400 3=300 4=200 5=100
recode fa_9 1=500 2=400 3=300 4=200 5=100
recode fa_1 500=5 400=4 300=3 200=2 100=1
recode fa_2 500=5 400=4 300=3 200=2 100=1
recode fa_3 500=5 400=4 300=3 200=2 100=1
recode fa_4 500=5 400=4 300=3 200=2 100=1
recode fa_5 500=5 400=4 300=3 200=2 100=1
recode fa_6 500=5 400=4 300=3 200=2 100=1
recode fa_7 500=5 400=4 300=3 200=2 100=1
recode fa_8 500=5 400=4 300=3 200=2 100=1
recode fa_9 500=5 400=4 300=3 200=2 100=1
*均值法
g fe =(fa_1+fa_2+fa_3+fa_4+fa_5+fa_6+fa_7+fa_8+fa_9)/9 	

egen fa2=rowmean(fa_1 fa_2 fa_3 fa_4 fa_5 fa_6 fa_7 fa_8 fa_9)

		 
sum fe
*因子分析法
factor fa_1 - fa_9, pcf
*生成因子分
predict f_fe // 法治环境感知

rotate
*KMO检验
estat kmo
*bartlett球形检验
 *ssc install factortest // 然后安装，装好之后输入： 
factortest fa_1 - fa_9 
*信度系数 （Cronbach's α） - 针对某一公因子包括的观测指标
alpha fa_1 - fa_9

/***筛选变量
keep year firm_year employee log_employee  ///
	interest_total interest_of ///
	indus_1 indus_2 indus_3 indus_real ///
	gender edu_cate edu_dummy party_mem renda zhengxie twocm gongshanglian status_e status_s status_p status_tl ///
	structure_party ///
	revenue_latest log_revenue_latest profit_latest log_profit_latest ///
	invest log_invest invest_dummy invest_ratio log_invest_ratio  ///
	inno_in log_inno_in inno_in_dummy inno_in_ratio inno_out ///
	loan_bank log_loan_bank ///
	subsidy log_subsidy ///
	tanpai log_tanpai tanpai_dummy tanpai_ratio yingchou log_yingchou yingchou_dummy yingchou_ratio guifei log_guifei guifei_dummy guifei_ratio //
	juan log_juan juan_dummy juan_ratio zhiwu log_zhiwu zhiwu_dummy zhiwu_ratio ///
	wage log_wage per_wage log_per_wage ///
	ins_fare log_ins_fare ins_num ins_fare_dummy per_ins_fare log_per_ins_fare ins_num_ratio ///
	en_1 en_2 en_3 en_4 en_5 en_6 en_7 en_8 en_9 en_10 en_11 en_12 be f_be ///
	fa_1 fa_2 fa_3 fa_4 fa_5 fa_6 fa_7 fa_8 fa_9 fe f_fe ///
	prov diqu
*/
**********************************
***构建家族涉入的新指标(虚拟变量)
**********************************
g interest_of_dy = .
replace interest_of_dy =0 if interest_of < 50
replace interest_of_dy =1 if interest_of > 49.9999999 & interest_of < 101
tab interest_of_dy

*keep if interest_of_dy==1

******************************
***数据清理(各章数据都适用)***
******************************
*注：在各章内部再进行清理
*structure_party i.interest_of_dy c.log_employee  party_ind i.party_mem c.firm_year ///
*c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
*ins_num_ratio

/*
drop if structure_party == .
*drop if ins_num_ratio==.
drop if interest_of==.
drop if log_employee == .
drop if party_ind ==.
drop if party_mem == .
drop if firm_year==.
drop if log_profit_latest== .
drop if industry_man==.
drop if firm_year==.
drop if gender == .
drop if edu_dummy == .
drop if twocm == .
drop if prov == .
*final sample:
*/



***label variables
lab var structure_party "Build a Party Branch"
lab var ins_num_ratio "Percent of Employees with Social Securities"
lab var interest_of "Family Involvement"
lab var log_employee "Firm size (logged)"
lab var employee "Firm size"
*lab var party_ind "Percent of Party building in an industry"
lab var firm_year "Firm age"
lab var profit_latest_w "Firm profit(winsorized)"
lab var industry_man "Manufacturing"
lab var gender "Male"
lab var edu_dummy "College education and above"
lab var twocm "Congress delegates or CCPCC members"
lab var party_mem "Party members"


**summary statistics

asdoc sum  structure_party ins_num_ratio interest_of employee  party_ind party_mem firm_year ///
profit_latest_w industry_man gender edu_dummy twocm,replace(table 2) dec(2) label





**********************
***select variables***
**********************
***Chapter 6 设立党组织
*g year = 2018

/*keep year structure_party interest_of interest_of_dy  ///
	      firm_year employee log_employee revenue_latest log_revenue_latest ///
			profit_latest log_profit_latest indus_real ///
			age gender edu_dummy party_mem twocm gongshanglian status_tl status_s status_p status_e ///
			prov diqu fe f_fe be f_be ///
			revenue_latest_w log_revenue_latest_w profit_latest_w log_profit_latest_w // 缩尾

***Chapter 7 社会功能
g year = 2018
keep year structure_party interest_of interest_of_dy  ///
	      firm_year employee log_employee revenue_latest log_revenue_latest ///
			profit_latest log_profit_latest indus_real ///
			age gender edu_dummy party_mem twocm gongshanglian status_tl status_s status_p status_e ///
			diqu prov ///
			juan log_juan juan_dummy juan_ratio zhiwu log_zhiwu zhiwu_dummy zhiwu_ratio ///
			wage per_wage ///
			ins_fare log_ins_fare ins_num ins_fare_dummy per_ins_fare ins_num_ratio /// 
			revenue_latest_w log_revenue_latest_w profit_latest_w log_profit_latest_w /// 缩尾
			juan_w log_juan_w juan_ratio_w zhiwu_w log_zhiwu_w zhiwu_ratio_w /// 缩尾
			per_wage_w log_per_wage_w per_ins_fare_w log_per_ins_fare_w  // 缩尾

***Chapter 8 经济功能
g year = 2018
keep year structure_party interest_of interest_of_dy  ///
	      firm_year employee log_employee revenue_latest log_revenue_latest ///
			profit_latest log_profit_latest indus_real ///
			age gender edu_dummy party_mem twocm gongshanglian status_tl status_s status_p status_e ///
			diqu prov ///
			invest log_invest invest_dummy invest_ratio ///
			inno_in inno_in_dummy inno_in_ratio inno_out ///
			loan_bank log_loan_bank ///
			subsidy log_subsidy ///
			tanpai log_tanpai tanpai_dummy tanpai_ratio ///
			yingchou log_yingchou yingchou_dummy yingchou_ratio ///
			guifei log_guifei guifei_dummy guifei_ratio ///
			revenue_latest_w log_revenue_latest_w profit_latest_w log_profit_latest_w /// 缩尾
			invest_w log_invest_w invest_ratio_w /// 缩尾
			loan_bank_w log_loan_bank_w subsidy_w log_subsidy_w // 缩尾

 
***Chapter 9 脱耦 不理想
g year = 2018
keep year structure_party interest_of interest_of_dy  ///
	      firm_year employee log_employee revenue_latest log_revenue_latest ///
			profit_latest log_profit_latest indus_real ///
			age gender edu_dummy party_mem twocm gongshanglian status_tl status_s status_p status_e ///
			prov diqu fe f_fe be f_be ///
			juan log_juan juan_dummy juan_ratio zhiwu log_zhiwu zhiwu_dummy zhiwu_ratio ///
			wage per_wage ///
			ins_fare log_ins_fare ins_num ins_fare_dummy per_ins_fare ins_num_ratio ///
			invest log_invest invest_dummy invest_ratio ///
			inno_in inno_in_dummy inno_in_ratio inno_out ///
			loan_bank log_loan_bank ///
			subsidy log_subsidy ///
			tanpai log_tanpai tanpai_dummy tanpai_ratio ///
			yingchou log_yingchou yingchou_dummy yingchou_ratio ///
			guifei log_guifei guifei_dummy guifei_ratio ///
			firm_shuji concurrent ///
			f_s1 f_s2 f_s3 f_s4 f_x1 f_x2 f_x3 party_func
*/			
			
********************************=********************************=**************
*************************************** 描述性分析 ******************************
********************************=********************************=**************

*sumup gender age edu_dummy, by(structure_party)

/*企业主个体特征
tab structure_party gender, col chi2
ttest age, by(structure_party)
tab structure_party edu_dummy, col chi2
tab structure_party party_mem, col chi2
tab structure_party twocm, col chi2
tab structure_party gongshanglian, col chi2
ttest status_e , by(structure_party)
ttest status_p, by(structure_party)
ttest status_s, by(structure_party)
ttest be, by(structure_party)
ttest f_be, by(structure_party)
ttest en_1, by(structure_party)
ttest en_2, by(structure_party)
ttest en_3, by(structure_party)
ttest en_4, by(structure_party)
ttest en_5, by(structure_party)
ttest en_6, by(structure_party)
ttest en_7, by(structure_party)
ttest en_8, by(structure_party)
ttest en_9, by(structure_party)
ttest en_10, by(structure_party)
ttest en_11, by(structure_party)
ttest en_12, by(structure_party)

*企业主组织特征
tab V71 structure_party, col chi2
ttest firm_year, by(structure_party)
tab regi_type structure_party, col chi2
ttest interest_of, by(structure_party)
ttest employee, by(structure_party)
ttest interest_total, by(structure_party)

ttest juan, by(structure_party)
ttest zhiwu, by(structure_party)

ttest wage, by(structure_party)
ttest per_wage, by(structure_party)
ttest wage_ratio, by(structure_party)

ttest ins_fare, by(structure_party)
ttest ins_fare_ratio, by(structure_party)
ttest ins_num, by(structure_party)
ttest ins_num_ratio, by(structure_party)

ttest loan_bank, by(structure_party)
ttest subsidy, by(structure_party)

ttest tanpai, by(structure_party)
ttest yingchou, by(structure_party)
ttest guifei, by(structure_party)

ttest invest, by(structure_party)
ttest invest_ratio, by(structure_party)

ttest inno_in, by(structure_party)
ttest inno_in_ratio, by(structure_party)
ttest inno_out, by(structure_party)

ttest revenue_latest, by(structure_party)
ttest profit_latest, by(structure_party)

*区域分布
tab diqu structure_party, col chi2
tab prov structure_party, col chi2
*/


********************************=********************************=**************
*************************************** 回归分析 ******************************
********************************=********************************=**************

***Table 1：家族控制对设立党组织的影响
*g interest_of_dy = interest_of
*replace interest_of_dy =0 if interest_of_dy < 50.00000001
*replace interest_of_dy =1 if interest_of_dy > 50
*tab interest_of_dy

set more off

**模型1
/*
logit structure_party c.interest_of i.party_mem  c.firm_year c.profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov 
eststo m0


logit structure_party c.interest_of i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm
eststo m1


logit structure_party  c.log_employee party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m2
*/

drop if c.log_employee==.

logit structure_party c.interest_of i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m1
	
		
logit structure_party c.interest_of c.log_employee  i.party_mem c.firm_year ///
c.log_profit_latest_w i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m2


**robustness check


/*
logit structure_party c.interest_of c.log_employee##c.party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m3


logit structure_party c.interest_of c.log_employee##c.interest_of c.party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m4

logit structure_party c.interest_of c.party_ind##c.interest_of c.party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m5
*/

/*
logit firm_shuji c.interest_of party_ind i.party_mem c.firm_year  c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov if structure_party==1
eststo m3

logit firm_shuji c.interest_of c.log_employee  party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov if structure_party==1
eststo m4
*/

esttab m1 m2 using decouple_2018.rtf, b(3) se(3) pr2 star(* 0.05 ** 0.01 *** 0.001) ///
nobase replace drop(*.prov*)



**参保率

***********************
***social security
***********************
regress ins_num_ratio c.interest_of i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov if structure_party==1 
eststo m5 


regress ins_num_ratio c.interest_of i.party_mem structure_party c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov 
eststo m6


esttab m5 m6 using socrate_2018.rtf, b(3) se(3) r2 star(* 0.05 ** 0.01 *** 0.001) ///
nobase replace drop(*.prov*)




*********************
***制度环境的作用
*********************
logit structure_party c.interest_of##c.en_total2 i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m7


regress ins_num_ratio c.interest_of##c.en_total2 i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m8


logit structure_party c.interest_of##c.fa2 i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m9


regress ins_num_ratio c.interest_of##c.fa2 i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m10


esttab m7 m8 m9 m10 using instenv_2018.rtf, b(3) se(3) pr2 r2 star(* 0.05 ** 0.01 *** 0.001) ///
nobase replace drop(*.prov*)
 
exit


*****robustness checks
logit structure_party c.interest_of##c.f_be i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m71


regress ins_num_ratio c.interest_of##c.f_be i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m81


logit structure_party c.interest_of##c.f_fe i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m91


regress ins_num_ratio c.interest_of##c.f_fe i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m101


esttab m71 m81 m91 m101 using instenv_2018_r.rtf, b(3) se(3) pr2 r2 star(* 0.05 ** 0.01 *** 0.001) ///
nobase replace drop(*.prov*)

exit


**IV regressions

ivregress 2sls structure_party c.log_employee   i.party_mem c.firm_year ///
c.log_profit_latest_w i.industry_man i.gender i.edu_dummy i.twocm i.prov (c.interest_of=V185),vce(robust)
eststo m11


ivregress 2sls ins_num_ratio c.log_employee   i.party_mem c.firm_year ///
c.log_profit_latest_w i.industry_man i.gender i.edu_dummy i.twocm i.prov (c.interest_of=V185),vce(robust) 
eststo m12

esttab m11 m12 using iv_2018_r.rtf, b(3) se(3) pr2 r2 star(* 0.05 ** 0.01 *** 0.001) ///
nobase replace drop(*.prov*)


**IVs
winsor v60,gen(Wrelative) p(0.01)
gen relative_ln=ln(Wrelative)

ivregress 2sls structure_party c.log_employee  party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov (c.interest_of=relative_ln),vce(robust) first 
eststo m13

ivregress 2sls ins_num_ratio c.log_employee  party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov (c.interest_of=relative_ln),vce(robust) first 
eststo m13



***Factors 

regress ins_num_ratio c.interest_of i.structure_party##c.en_total2 i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov


logit structure_party c.interest_of##c.fa2 i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov



regress ins_num_ratio i.structure_party##c.fa2 i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov





logit structure_party c.interest_of##c.en_total2 i.party_mem  c.firm_year c.log_profit_latest_w ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov



regress ins_num_ratio c.interest_of##c.en_total2 i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov




exit
	

probit structure_party c.interest_of_dy i.party_mem  c.firm_year c.log_profit_latest ///
i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo
	
probit structure_party c.interest_of_dy  i.party_mem c.log_employee party_ind c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo	

esttab using chapter6_t7_2018.rtf, b(3) se(3) pr2 star(* 0.10 ** 0.05 *** 0.01) nobase replace



**environment
logit  structure_party c.interest_of## c.log_employee  party_ind i.party_mem c.firm_year ///
c.log_profit_latest i.industry_man i.gender i.edu_dummy i.twocm i.prov
eststo m2



eststo clear


//"结果：不显著"
//"结果：管制合法性变大时，家族企业会设立党组织"

***Table 2:制度环境与设立党组织***
/*制度环境感知*/
probit structure_party c.f_be c.firm_year c.log_employee c.log_profit_latest c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
probit structure_party c.be c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
//"结果:制度环境感知越好，越建立党组织"

***Table 3:制度环境、家族涉入与设立党组织***
probit structure_party c.f_be##c.interest_of c.firm_year c.log_employee c.log_profit_latest i.industry_man i.gender i.edu_dummy i.party_mem i.twocm i.prov
//"结果:制度环境感知越好，可以促进家族企业设立党组织"

/*地位感知*/
probit structure_party c.status_e c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
probit structure_party c.status_s c.firm_year c.log_employee c.log_profit_latest c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
probit structure_party c.status_p c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
probit structure_party c.status_tl c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
//"结果：社会地位和政治地位显著"

probit structure_party c.status_e##c.interest_of c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
probit structure_party c.status_s##c.interest_of c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
probit structure_party c.status_p##c.interest_of c.firm_year c.log_employee c.log_profit_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

***Table 2:党组织对企业绩效的影响***

/*企业绩效*/
*销售收入 yes
reg log_revenue_latest i.structure_party c.firm_year c.log_employee c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
*净利润 yes
reg log_profit_latest i.structure_party c.firm_year c.log_employee c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

/*新增投资*/
*投资额 no
reg log_invest i.structure_party c.firm_year c.log_employee c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
*新增投资/销售收入 yes
reg log_invest i.structure_party c.firm_year c.log_employee c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

/*资源获取*/
*银行贷款
reg log_loan_bank i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

/*行政干预*/
*摊派 no
reg log_tanpai i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
*应酬 no
reg log_yingchou i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
*规费 no
reg log_guifei i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

/*内部社会责任*/
*工资 no
reg log_wage i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
reg log_per_wage i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
*劳保 null
*社保 no
reg log_per_ins_fare i.structure_party c.interest_of c.firm_year c.log_employee c.log_revenue_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

reg ins_fare_ratio i.structure_party c.interest_of c.firm_year c.log_employee c.log_revenue_latest
probit ins_fare_dummy i.structure_party c.interest_of c.firm_year c.log_employee c.log_revenue_latest

*培训 
*合同签订
/*外部社会责任*/
*捐赠 yes
reg log_juan i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of  i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov
reg juan_ratio i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov


**人均
gen socinsure=V96/V97

gen socinsure_ln=ln(socinsure)

regress socinsure_ln i.structure_party c.firm_year c.log_employee c.log_revenue_latest c.interest_of  ///
i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

regress ins_num_ratio i.structure_party c.interest_of c.firm_year c.log_employee c.log_revenue_latest c.interest_of  ///
i.indus_real i.gender i.edu_dummy i.party_mem i.twocm i.prov

exit
